package cn.group01.git.controller;

import cn.group01.git.common.ResponseResult;
import cn.group01.git.dto.TemplatePage;
import cn.group01.git.service.TemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

// 模板
@Controller
@RequestMapping("template")
public class TemplateController {

    @Autowired
    private TemplateService templateService;

    // 上传文件
    @RequestMapping("upload")
    @ResponseBody
    public ResponseResult upload(MultipartFile file){
        return templateService.upload(file);
    }

    // 上传文件
    @RequestMapping("list")
    @ResponseBody
    public ResponseResult getList(TemplatePage templatePage){
        return templateService.getList(templatePage);
    }

    // 下载文件
    @RequestMapping("down")
    @ResponseBody
    public void  download(String fileName, HttpServletResponse response){
         templateService.download(fileName, response);
    }
}
